{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $op == 'post'}class="active"{/if}><a href="{php echo $this->wurl('poster', array('op' => 'post'))}">添加海报</a></li>
	<li {if $op == 'display'}class="active"{/if}><a href="{php echo $this->wurl('poster')}">海报列表</a></li>
</ul>
{if $op == 'display'}
<style>
th{
	text-align: center !important;
}
td{
	text-align: center !important;
	white-space: normal !important;
	word-break: break-all !important;
	vertical-align: middle !important;
}
</style>
<form action="" method="get" class="form-horizontal" role="form">
	<div class="panel panel-info">
        <div class="panel-heading">筛选</div>
			<div class="panel-body">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{php echo $this->modulename}" />
                <input type="hidden" name="do" value="poster" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">类型</label>
                    <div class="col-xs-12 col-sm-2 col-lg-2">
                        <select name="type" class="form-control">
                        	<option value="">全部</option>
                        	<option value="0" {if empty($_GPC['type']) && $_GPC['type']!=''}selected{/if}>考试结果</option>
                        	<option value="1" {if $_GPC['type']==1}selected{/if}>学生证</option>
                        	<option value="2" {if $_GPC['type']==2}selected{/if}>听课打卡</option>
                        </select>
                    </div>
					<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
                    <div class="col-xs-12 col-sm-2 col-lg-2">
                        <select name="status" class="form-control">
                        	<option value="">全部</option>
                        	<option value="0" {if empty($_GPC['status']) && $_GPC['status']!=''}selected{/if}>隐藏</option>
                        	<option value="1" {if $_GPC['status']==1}selected{/if}>启用</option>
                        </select>
                    </div>
                	<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"></label>
                    <div class=" col-xs-12 col-sm-3 col-lg-3">
                        <button class="btn btn-sm btn-default" ><i class="fa fa-search"></i> 搜索</button>
                   	</div>
				</div>
			</div>
        </div>
</form>			
<div class="main">
	<div class="cate" style="background: white;">
		<table class="table table-hover">
			<thead>
				<tr>
					<th>类型</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
			{loop $list $item}
				<tr>
					<td>
					{if $item['type']==1}
					<label class="label label-success">学生证</label>
					{elseif $item['type']==2}
					<label class="label label-primary">听课打卡</label>
					{else}
					<label class="label label-info">考试结果</label>
					{/if}
					</td>
					<td>{if $item['status']}<label class="label label-success">启用</label>{else}<label class="label label-default">隐藏</label>{/if}</td>
					<td>
						<a class="btn btn-sm btn-default" href="{php echo $this->wurl('poster', array('op' => 'post', 'id' => $item['id']))}"><i class='fa fa-edit'></i>编辑</a>
						<a onclick="return confirm('确定删除吗？');return false;" href="{php echo $this->wurl('poster',array('op'=>'del','id'=>$item['id']))}" class="btn btn-sm btn-danger"><i class="fa fa-remove"></i> 删除</a>
					</td>
				</tr>
			{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>
{/if}
{if $op == 'post'}
<style>
.settings{
	display: none;
}
</style>
<ul class="nav nav-tabs" id="snav">
	<li class="active"><a>基础设置</a></li>
	<li><a>海报设置</a></li>
</ul>
<script>
$('#snav li').click(function(){
	$('#snav li').removeClass('active');
	$(this).addClass('active');
	$('.settings').hide();
	$('.settings').eq($(this).index()).show();
});
</script>

<div class="main">
<form action="" method="post" class="form-horizontal form">
<input type="hidden" name="id" value="{$id}" />
<div class="settings" style="display:block;">
        <div class="panel panel-default">
            <div class="panel-heading">
                详情设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">海报类型</label>
                    <div class="col-sm-9 col-xs-12">
                        <label class="radio-inline"><input type="radio" name="type" value="0" {if $id}disabled{/if} {if $item['type']==0}checked{/if}>考试结果</label>
                        <label class="radio-inline"><input type="radio" name="type" value="1" {if $id}disabled{/if} {if $item['type']==1}checked{/if}>学生证</label>
                        <label class="radio-inline"><input type="radio" name="type" value="2" {if $id}disabled{/if} {if $item['type']==2}checked{/if}>听课打卡</label>
                    	<span class="help-block">海报类型选择后将无法更改</span>
                    </div>
                </div>
                <div class="form-group books" {if $item['type']!=2}style="display: none;"{/if}>
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">课程</label>
                    <div class="col-sm-9 col-xs-12">
                    	<select class="form-control" name="bid">
                    		<option value="0"> 请选择课程
                    		{loop $books $bk}
                    		<option value="{$bk['id']}" {if $bk['id']==$item['bid']}selected{/if}> {$bk['title']}
                    		{/loop}
                    	</select>
                    	<span class="help-block">打卡海报不选则课程则通用</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                    <div class="col-sm-9 col-xs-12">
                        <label class="radio-inline"><input type="radio" name="status" value="0" {if $item['status']==0}checked{/if}>隐藏</label>
                        <label class="radio-inline"><input type="radio" name="status" value="1" {if $item['status']==1}checked{/if}>启用</label>
                    	<span class="help-block">同一类型的海报只能有一个是有效的</span>
                    </div>
                </div>
			</div>
		</div>
</div>
<script>
$('input[name=type]').change(function(){
	var ptype = $(this).val();
	if(ptype==1){
		$('#p-bday').hide();
		$('#p-score').hide();
		$('#p-num').hide();
		$('#p-rate').hide();
		$('#p-dict').hide();
		$('#p-sid').show();
		$('#p-sday').show();
		$('.books').hide();
	}
	else if(ptype==2){
		$('#p-score').hide();
		$('#p-num').hide();
		$('#p-rate').hide();
		$('#p-dict').hide();
		$('#p-sid').hide();
		$('#p-sday').hide();
		$('#p-bday').show();
		$('.books').show();
	}
	else{
		$('#p-bday').hide();
		$('#p-score').show();
		$('#p-num').show();
		$('#p-rate').show();
		$('#p-dict').show();
		$('#p-sid').hide();
		$('#p-sday').hide();
		$('.books').hide();
	}
});
</script>
<div class="settings">
	{template 'poster'}
</div>		
<input name="submit" type="submit" value="提交" class="btn btn-sm btn-primary span3">
<input type="hidden" name="token" value="{$_W['token']}" />
</form>
</div>
{/if}
{template 'common/footer'}
